package struts.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import struts.util.XmlBean;
import struts.util.XmlReader;
/**
 * 容器启动时加载xml对象
 * @author Zzq
 *
 */
public class ActionListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("信息：系统已注销。。。");
	}

	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext context = arg0.getServletContext();
		String xmlPath = context.getInitParameter("struts-config");
		String realPath = context.getRealPath("\\");
		
		Map<String, XmlBean> map = XmlReader.parse(realPath+xmlPath);
		context.setAttribute("struts", map);
		
		System.out.println("信息：系统加载完毕。。。。");
	}
	
}
